// (c) 2004 Wout de Zeeuw

using System;
using System.Collections;

namespace CaveArt.UIcomp
{
	public enum PropertyMode
	{
		ShowAll			= 0,
		ManagerSearch	= 1,
		ManagerItem		= 2,
		CashierSearch	= 3,
		CashierItem		= 4
	}

	/// <summary>
	/// Has some attributes defining how a property behaves in 
	/// a <see cref="System.Windows.Forms.PropertyGrid"/>.
	/// </summary>
	public class PropertyAttributes : IComparable
	{
		public static PropertyMode	Mode = PropertyMode.ShowAll;

		//public static Hashtable		readonlyhash	= new Hashtable();
		//public static Hashtable		hidehash		= new Hashtable();
		//public static bool			retainhash		= false;

		private string name;
		private string displayName;
	    private string description;
	    private string category;
		private int	   fieldindex;

		private bool	isBrowsable;
		private bool	isReadOnly;
	    
	    private int order = 0;
		
		public PropertyAttributes(string name) 
		{
			this.name = name;
		}
		
		#region PROPERTIES
		public string Name 
		{
			get {
				return name;
			}
		}

		public bool IsBrowsable {	
			get {
				return isBrowsable;
			}
			set {
				isBrowsable = value;
			}
		}

		public bool IsReadOnly {
			get {
				return isReadOnly;
			}
			set {
				isReadOnly = value;
			}
		}
		public string DisplayName {
			get {
				return displayName;
			}
			set {
				displayName = value;
			}
		}
		public string Description {
			get {
				return description;
			}
			set {
				description = value;
			}
		}
		public string Category {
			get {
				return category;
			}
			set {
				category = value;
			}
		}
		
		public int Order {
			get {
				return order;
			}
			set {
				order = value;
			}
		}

		public int FieldIndex 
		{
			get 
			{
				return fieldindex;
			}
			set 
			{
				fieldindex = value;
			}
		}
		#if READONLY_TEST
		public bool ReadOnly
		{
			get 
			{

				return isReadOnly;
			}
			set 
			{
				isReadOnly = value;
			}
		}
		#endif

		#endregion

		#region IComparable
		
		public int CompareTo(object obj)
		{
			// Compare this pair's order to another.  If the numeric order is the same, sort by display name.
			PropertyAttributes other = (PropertyAttributes)obj;
			if (order == other.order) {
				return string.Compare(displayName, other.displayName);
			} else {
				return (order < other.order) ? -1 : 1;
			}
		}
		
		#endregion
	}
}
